import random

from DefaultCard import *
from DefaultSet import *
from BaseSet import *
from Player import *


class Pile():
    def __init__(self, CardType, number=12):
        self.Set = deque()
        for i in range(number):
            self.Set.append(CardType())
        self.Name = CardType.Name
        self.Card = CardType
        
    def __str__(self):
        return "#"+self.Name+"# ["+str(self.size())+"]"

    def pop(self):
        if self.size()>0:
            return self.Set.pop()
        else:
            return None

    def buy(self,player):
        if player.getCoins()>=self.Card.Cost:
            player.buy(self.pop())

    def size(self):
        return len(self.Set)
